package com.yfqy.app.enums;

import lombok.Getter;

@Getter
public enum OrderItemStatus {

    /**
     * 无退款
     */
    NO_REFUND((byte) 0, "无退款"),

    /**
     * 退款中
     */
    REFUNDING((byte) 1, "退款中"),

    /**
     * 已退款
     */
    REFUNDED((byte) 2, "已退款");

    private final Byte status;
    private final String description;

    OrderItemStatus(Byte status, String description) {
        this.status = status;
        this.description = description;
    }

    /**
     * 根据状态值获取枚举
     */
    public static OrderItemStatus fromStatus(Byte status) {
        if (status == null) {
            return null;
        }
        for (OrderItemStatus refundStatus : values()) {
            if (refundStatus.getStatus().equals(status)) {
                return refundStatus;
            }
        }
        return null;
    }

    /**
     * 检查状态值是否有效
     */
    public static boolean isValidStatus(Byte status) {
        return fromStatus(status) != null;
    }


}
